#/* ------------------------------------------------------------------------------
# * Copyright (c) 2006 Novell, Inc. All Rights Reserved.
# *
# *
# * This program is free software; you can redistribute it and/or modify it under
# * the terms of version 2 of the GNU General Public License as published by the
# * Free Software Foundation.
# *
# * This program is distributed in the hope that it will be useful, but WITHOUT
# * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
# *
# * You should have received a copy of the GNU General Public License along with
# * this program; if not, contact Novell, Inc.
# *
# * To contact Novell about this file by physical or electronic mail, you may find
# * current contact information at www.novell.com.
# * ------------------------------------------------------------------------------
# */
#
#/**
# * File:        include/qwe/wizards.ycp
# * Package:        Configuration of qwe
# * Summary:        Wizards definitions
# * Authors:        jeff <jeff>
# */

################################################################################
# Imports
################################################################################

import EducationComplex

import ycp
from ycp import *

import_module("Sequencer")
import_module("UI")
import_module("Wizard")

import gettext
gettext.install("education")

################################################################################
# Functions
################################################################################

#/**
# * Main workflow of the Education configuration
# * @return sequence result
# */
def MainSequence():

    aliases = {
        "system_usage": Code(EducationComplex.SystemUsageDialog),
        "age_group" : Code(EducationComplex.AgeGroupDialog),
        "groups": Code(EducationComplex.GroupsDialog),
        "users": Code(EducationComplex.UsersDialog),
        "add_group": Code(EducationComplex.AddEditGroupDialog),
        "add_user": Code(EducationComplex.AddEditUsersDialog),
        "advanced_group" : Code(EducationComplex.AdvancedGroupsDialog),
        "web_filtering" : Code(EducationComplex.WebFilteringDialog),
        "edit_filter" : Code(EducationComplex.EditWebFilterDialog),
        "access_time" : Code(EducationComplex.AccessTimeDialog),
        "edit_access_times" : Code(EducationComplex.EditAccessTimeRestrictions),
        "firewall" : Code(EducationComplex.FirewallDialog)
    }
    
    sequence = {
        "ws_start": "system_usage",
        #"ws_start": "access_time",
        "system_usage": {
            Symbol("abort"): Symbol("abort"),            
            Symbol("desktop"): "age_group",
            Symbol("server"): Symbol("abort")   #TODO: Fix me later
        },
        "age_group": {
            Symbol("abort"): Symbol("abort"),
            Symbol("next"): "groups"
        },
        "groups": {
            Symbol("abort"): Symbol("abort"),
            Symbol("add_group"): "add_group",
            Symbol("edit_group"): "add_group",            
            Symbol("next"): "users"
        },
        "users": {
            Symbol("abort"): Symbol("abort"),
            Symbol("add_user"): "add_user",
            Symbol("edit_user"): "add_user",           
            Symbol("next"): "web_filtering"
        },
        "add_group": {
            Symbol("abort"): Symbol("abort"),
            Symbol('cancel'): "groups",
            Symbol('next'): "groups",
            Symbol('advanced'): "advanced_group"
        },
        "add_user": {
            Symbol("abort"): Symbol("abort"),
            Symbol('cancel'): "users",
            Symbol('next'): "users"
        },
        "advanced_group" : {
            Symbol("abort"): Symbol("abort"),
            Symbol("cancel"): "add_group",
            Symbol("next"): "add_group"
        },
        "web_filtering" : {
            Symbol("abort"): Symbol("abort"),
            Symbol("edit_filter"): "edit_filter",
            Symbol("back"): "users",
            Symbol("next"): "access_time"
        },
        "edit_filter" : {
            Symbol("abort"): Symbol("abort"),            
            Symbol("back"): "web_filtering",
            Symbol("next"): "web_filtering"
        },
        "access_time" : {
            Symbol("abort"): Symbol("abort"),
            Symbol("edit_restrictions"): "edit_access_times",
            Symbol("back"): "web_filtering",
            Symbol("next"): "firewall"
        },
        "edit_access_times" : {
          Symbol("abort"): Symbol("abort"),
          Symbol("back"): "access_time",
          Symbol("next"): "access_time"
        },
        "firewall" : {
            Symbol("abort"): Symbol("abort"),
            Symbol("back"): "access_time",
            Symbol("next"): Symbol("next")
        }
    }
    
    ret = ycp.Sequencer.Run(aliases, sequence);
    return ret

#/**
# * Whole configuration of Education
# * @return sequence result
# */
def EducationSequence():
    
    ycp.Wizard.CreateDialog()
    
    aliases = {
        "read": [Code(EducationComplex.ReadDialog), True],
        "main":  Code(MainSequence),
        "write": Code(EducationComplex.WriteDialog)
    }
    
    sequence = {
        "ws_start": "read",
        "read": {
            Symbol("abort"): Symbol("abort"),
            Symbol("next"): "main"
        },
        "main": {
            Symbol("abort"): Symbol("abort"),
            Symbol("next"): "write"
        },
        "write": {
            Symbol("abort"): Symbol("abort"),
            Symbol("next"): Symbol("next")
        }
    }
    
    
    #ycp.Wizard.SetTitleIcon("yast2-education")

    ret = ycp.Sequencer.Run(aliases, sequence)
    
    UI.CloseDialog()
    return ret
